//
//  BKMyOrderCellFootView.m
//  bestkeep
//
//  Created by Mr. Wu on 16/12/6.
//  Copyright © 2016年 utouu. All rights reserved.
//

#import "BKMyOrderCellFootView.h"
#import "UIButton+BKMyOrderButton.h"
#import "BK_OD_Color.h"
#import "BK_OD_Tool.h"
#define FONT_BTN            13.0 //按钮font
#define HEIGHT_Btn_right  27
#define HEIGHT_Footer_Down  43
#define BORDERWIDTH         0.6 //边框宽度
#define CORNERRADIUS        5  //圆角
#define BACKCOLOR_BTN       [UIColor whiteColor] //按钮背景颜色
#define FONT_TEXT_ONE          13
@implementation BKMyOrderCellFootView
- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor=[UIColor whiteColor];
        [self initView];
    }
    
    return self;
}
- (void)initView{
    _lab_detail=[[UILabel alloc]init];
    _lab_detail.textColor =kOrderBlack1;
    _lab_detail.font = [UIFont systemFontOfSize:13];
    _lab_detail.text = @"共1件商品 合计：￥0.00(含运费￥0.00)";
    _lab_detail.backgroundColor = [UIColor clearColor];
    [self addSubview:_lab_detail];
    _lab_detail.textAlignment=NSTextAlignmentRight;
    
    [_lab_detail mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.mas_right).offset(-ApplicationBackGauge);
        make.top.mas_equalTo(@(0));
        make.height.mas_equalTo(@(28));
    }];

    _view_line=[[UIView alloc]init];
    _view_line.backgroundColor=RGB(230, 230, 230);
    [self addSubview:_view_line];
    [_view_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(0);
        make.left.equalTo(self.mas_left);
        make.top.mas_equalTo(@(30));
        make.height.mas_equalTo(@(0.7));
    }];
    
    _view_down=[[UIView alloc]init];
    _view_down.backgroundColor=[UIColor clearColor];
    [self addSubview:_view_down];
    [_view_down mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(0);
        make.left.equalTo(self.mas_left);
        make.top.mas_equalTo(@(31));
        make.height.mas_equalTo(@(HEIGHT_Footer_Down));
    }];
    self.bottomView = [BKMyOrderBottomView new];
    [_view_down addSubview:self.bottomView];
    
    [self.bottomView.btn_right_one addTarget:self action:@selector(click_btn:) forControlEvents:UIControlEventTouchUpInside];
    [self.bottomView.btn_right_two addTarget:self action:@selector(click_btn:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.bottomView.btn_right_three addTarget:self action:@selector(click_btn:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.bottomView.btn_right_four addTarget:self action:@selector(click_btn:) forControlEvents:UIControlEventTouchUpInside];
    [_bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(_view_down.mas_right);
        make.left.mas_equalTo(_view_down.mas_left);
        make.top.mas_equalTo(_view_down.mas_top);
        make.bottom.mas_equalTo(_view_down.mas_bottom);
    }];
}
#pragma ============= delegate
-(void)click_btn:(UIButton *)btn{
    if ([self.sectionDelegate respondsToSelector:@selector(BK_OrderFooter_Delegate_Click: AndModel:)]) {
        [self.sectionDelegate BK_OrderFooter_Delegate_Click:btn.titleLabel.text AndModel:self.model];
    }
}

-(void)fillData:(id)data{
    self.model = data;
    
    BK_My_Order_SectionModel *section = data;
    BK_My_Order_rows_Model *model = section.model_Order_rows;
    _Tobepaid =model.status_name;
    _oread_no_buy = model.order_no;
    _iscancel=model.own_cancel_flag;
    //共%@件商品 合计：%@(含运费￥%@)
    
    

    NSString * str  = [NSString stringWithFormat:@"共%@件商品 合计：%@(含运费%@)",model.amount,[NSString stringWithFormat:@"¥ %.2f",[model.order_amount floatValue]],[NSString stringWithFormat:@"¥ %.2f",[model.express_amount floatValue]]];

    NSString * str_total_amount=[NSString stringWithFormat:@"¥ %.2f",[model.order_amount floatValue]];
    

    
    NSMutableAttributedString *attri_lab_detail =[[NSMutableAttributedString alloc] initWithString:str];
    
    NSRange range = [str rangeOfString:  str_total_amount];
    
    [attri_lab_detail addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:16] range:range];
    
    _lab_detail.attributedText = attri_lab_detail;
    
    
//    _lab_detail.text =[NSString stringWithFormat:@"共%@件商品 合计：%@(含运费￥%@)",model.amount,[NSString stringWithFormat:@"¥ %.2f",[model.order_amount floatValue]],model.express_amount] ;
    _bottomView.orderModel = model;
    
    
    
    
    
    
    
}

@end
//
//@implementation BKMyOrderRecommendFootView
//- (instancetype)initWithFrame:(CGRect)frame{
//    self = [super initWithFrame:frame];
//    if (self) {
//        
//        [self initView];
//    }
//    return self;
//}
//
//-(void)initView{
//    UIView *recommentFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 85)];
//    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 5, 40, 40)];
//    UILabel *promptLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 150, 20)];
//    [recommentFooterView addSubview:promptLabel];
//    promptLabel.text = @"Sorry，暂时没有了~";
//    [promptLabel setTextAlignment:NSTextAlignmentCenter];
//    promptLabel.font = Font12;
//    promptLabel.backgroundColor = [UIColor clearColor];
//    promptLabel.textColor = RGB(182, 182, 182);
//    [recommentFooterView addSubview:imageView];
//    
//    CGPoint center = recommentFooterView.center;
//    imageView.center = CGPointMake(center.x, center.y-15);
//    promptLabel.center = CGPointMake(center.x, center.y+20);
//    imageView.image = [UIImage imageNamed:@"BKFooterNoMore"];
//    //设置左右label的渐变色
//    UILabel *leftLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 1)];
//    UILabel *rightLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 1)];
//    leftLabel.backgroundColor = [UIColor clearColor];
//    rightLabel.backgroundColor = [UIColor clearColor];
//    [recommentFooterView addSubview:leftLabel];
//    [recommentFooterView addSubview:rightLabel];
//    leftLabel.center = CGPointMake(center.x - 80, center.y-15);
//    rightLabel.center = CGPointMake(center.x + 80, center.y-15);
//    CAGradientLayer *leftGradientLayer = [CAGradientLayer layer];
//    leftGradientLayer.frame = leftLabel.frame;
//    leftGradientLayer.type = kCAGradientLayerAxial;
//    leftGradientLayer.cornerRadius = 0.5f;
//    leftGradientLayer.masksToBounds = YES;
//    leftGradientLayer.colors = [NSArray arrayWithObjects:(id)RGB(242, 242, 242).CGColor, (id)RGB(220, 220, 220).CGColor, nil];
//    leftGradientLayer.startPoint = CGPointMake(0, 0.5);
//    leftGradientLayer.endPoint = CGPointMake(1, 0.5);
//    //        leftGradientLayer.locations = [NSArray arrayWithObjects: @0.1, @0.3, nil];
//    [recommentFooterView.layer insertSublayer:leftGradientLayer atIndex:0];
//    CAGradientLayer *rightGradientLayer = [CAGradientLayer layer];
//    rightGradientLayer.frame = rightLabel.frame;
//    rightGradientLayer.colors = [NSArray arrayWithObjects:(id)RGB(220, 220, 220).CGColor, (id)RGB(242, 242, 242).CGColor, nil];
//    rightGradientLayer.startPoint = CGPointMake(0, 0.5);
//    rightGradientLayer.endPoint = CGPointMake(1, 0.5);
//    rightGradientLayer.type = kCAGradientLayerAxial;
//    rightGradientLayer.cornerRadius = 0.5f;
//    rightGradientLayer.masksToBounds = YES;
//    //        rightGradientLayer.locations = [NSArray arrayWithObjects: @0.7, @1.0, nil];
//    [recommentFooterView.layer insertSublayer:rightGradientLayer atIndex:0];
//    [self addSubview:recommentFooterView];
//    
//    
//    //   [self addSubview:[BKSCBuyCarTool getViewWhenDataEndLoading]];
//    
//}
//
//
//
//
//@end




